import { Application } from 'egg';

export default function(app: Application) {

  const { STRING, NOW, DATE, UUID, UUIDV4 } = app.Sequelize;

  const User = app.model.define(
    'files',
    {
      id: {
        type: UUID,
        field: 'id',
        allowNull: false,
        primaryKey: true,
        defaultValue: UUIDV4,
      },
      url: {
        type: STRING,
        allowNull: false,
      },
        fileName: {
            type: STRING,
            field: 'file_name',
            allowNull: false,
        },
        type: {
            type: STRING,
            field: 'type',
            allowNull: false,
        },
      createAt: {
        type: DATE,
        // 可以重写某个字段的字段名
        field: 'db_create_time',
        allowNull: false,
        defaultValue: NOW,
      },
      updateAt: {
        type: DATE,
        field: 'db_update_time',
        allowNull: false,
        defaultValue: NOW,
      },
    },
    {
      timestamps: false,
      freezeTableName: true,
      tableName: 'files',
      underscored: true,
    },
  );

  return class extends User {
    id:1;
  };
}
